package com.tianji.promotion.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.promotion.domain.query.UserCouponQuery;
import com.tianji.promotion.domain.vo.CouponVO;
import com.tianji.promotion.service.IUserCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户领取优惠券的记录，是真正使用的优惠券信息 前端控制器
 * </p>
 *
 * @author zhongweiwei
 * @since 2023-06-06
 */
@RestController
@Api("领取优惠卷相关接口")
@RequestMapping("/user-coupons")
@RequiredArgsConstructor
public class UserCouponController {
    private final IUserCouponService userCouponService;
    @PostMapping("{couponId}/receive")
    @ApiOperation("领取发放中的优惠卷接口")
    public void receiveCoupon(@PathVariable("couponId")Long couponId) {
        userCouponService.receiveCoupon(couponId);

    }
    @ApiOperation("兑换码兑换优惠卷接口")
@PostMapping("/{code}/exchange")
    public void exchangeCoupon(@PathVariable("code") String code){
        userCouponService.exchangeCoupon(code);
    }
    @GetMapping ("page")
    @ApiOperation("查询我的优惠卷")
    public PageDTO<CouponVO>queryMyCoupon(UserCouponQuery query){
          return userCouponService.queryMyCoupon(query);
    }



}
